<?php

namespace App\Http\Controllers\Base;

use App\Http\Repository\VideoChannelRepository;
use App\Http\Services\PicUrlService;
use App\Http\Controllers\Controller;
use App\Http\TraitClass\Response;
use Illuminate\Http\Request;

class VideoChannelController extends Controller
{
    use Response;

    private $_repository;

    public function __construct()
    {
        $this->_repository = new VideoChannelRepository();
    }

    public function index(Request $request)
    {
        $limit = $request->input('limit',6);

        $result = $this->_repository->getListByVideoChannelCategoryName(
            $request['video_channel_category_name'],
            $limit);

        $result = $this->returnPage($result);

        //处理字段
        foreach ($result['data']['items'] as $item) {
            $item->pic_url = PicUrlService::getPicUrl($item->pic_url);
        }

        return $result;
    }
}
